/*
ID:ning yusui
LANG:C++
TASK:game1
*/
#include<stdio.h>
#include<iostream>
#include<string.h>
int sum[101],n,a[101],points[101][101];
int search(int x,int y)
{
    if (points[x][y])return points[x][y];
    if (x==y)return points[x][y]=a[x];
    int t1,t2;
    t1=sum[y]-sum[x]-search(x+1,y)+a[x];
    t2=sum[y-1]-sum[x-1]-search(x,y-1)+a[y];
    return points[x][y]=std::max(t1,t2);
}
int main()
{
    freopen("game1.in","r",stdin);
    freopen("game1.out","w",stdout);
    scanf("%d",&n);
    for (int i=1;i<=n;i++)scanf("%d",&a[i]);
    sum[0]=0;
	for (int i=1;i<=n;i++)sum[i]=sum[i-1]+a[i];
	printf("%d ",search(1,n));
	printf("%d\n",sum[n]-points[1][n]);
    return 0;
}